package com.kjtpay.design_pattern.iterator;

class ConcreteIterator extends Iterator {
    private ConcreteAggregate aggregate;
    private int current = 0;

    public ConcreteIterator(ConcreteAggregate aggregate) {
        this.aggregate = aggregate;
    }

    @Override
    public Object first() {
        return aggregate.objectAtIndex(0);
    }

    @Override
    public Object next() {
        current++;
        return aggregate.objectAtIndex(current);
    }

    @Override
    public Boolean isDone() {
        return (current >= aggregate.count) ? true : false;
    }

    @Override
    public Object currentItem() {
        return aggregate.objectAtIndex(current);
    }
}
